# RUN: llvm-mc -triple=hexagon -disassemble < %s | FileCheck %s
# Hexagon Programmer's Reference Manual 11.10.5 XTYPE/MPY

# Multiply and use lower result
0xb1 0xdf 0x35 0xd7
# CHECK: r17 = add(#21,mpyi(r21,r31))
0xbf 0xd1 0x35 0xd8
# CHECK: r17 = add(#21,mpyi(r21,#31))
0xb5 0xd1 0x3f 0xdf
# CHECK: r17 = add(r21,mpyi(#84,r31))
0xf5 0xf1 0xb5 0xdf
# CHECK: r17 = add(r21,mpyi(r21,#31))
0x15 0xd1 0x1f 0xe3
# CHECK: r17 = add(r21,mpyi(r17,r31))
0xf1 0xc3 0x15 0xe0
# CHECK: r17 = +mpyi(r21,#31)
0xf1 0xc3 0x95 0xe0
# CHECK: r17 = -mpyi(r21,#31)
0xf1 0xc3 0x15 0xe1
# CHECK: r17 += mpyi(r21,#31)
0xf1 0xc3 0x95 0xe1
# CHECK: r17 -= mpyi(r21,#31)
0x11 0xdf 0x15 0xed
# CHECK: r17 = mpyi(r21,r31)
0x11 0xdf 0x15 0xef
# CHECK: r17 += mpyi(r21,r31)

# Vector multiply word by signed half (32x16)
0xb0 0xde 0x14 0xe8
# CHECK: r17:16 = vmpyweh(r21:20,r31:30):sat
0xb0 0xde 0x94 0xe8
# CHECK: r17:16 = vmpyweh(r21:20,r31:30):<<1:sat
0xf0 0xde 0x14 0xe8
# CHECK: r17:16 = vmpywoh(r21:20,r31:30):sat
0xf0 0xde 0x94 0xe8
# CHECK: r17:16 = vmpywoh(r21:20,r31:30):<<1:sat
0xb0 0xde 0x34 0xe8
# CHECK: r17:16 = vmpyweh(r21:20,r31:30):rnd:sat
0xb0 0xde 0xb4 0xe8
# CHECK: r17:16 = vmpyweh(r21:20,r31:30):<<1:rnd:sat
0xf0 0xde 0x34 0xe8
# CHECK: r17:16 = vmpywoh(r21:20,r31:30):rnd:sat
0xf0 0xde 0xb4 0xe8
# CHECK: r17:16 = vmpywoh(r21:20,r31:30):<<1:rnd:sat
0xb0 0xde 0x14 0xea
# CHECK: r17:16 += vmpyweh(r21:20,r31:30):sat
0xb0 0xde 0x94 0xea
# CHECK: r17:16 += vmpyweh(r21:20,r31:30):<<1:sat
0xf0 0xde 0x14 0xea
# CHECK: r17:16 += vmpywoh(r21:20,r31:30):sat
0xf0 0xde 0x94 0xea
# CHECK: r17:16 += vmpywoh(r21:20,r31:30):<<1:sat
0xb0 0xde 0x34 0xea
# CHECK: r17:16 += vmpyweh(r21:20,r31:30):rnd:sat
0xb0 0xde 0xb4 0xea
# CHECK: r17:16 += vmpyweh(r21:20,r31:30):<<1:rnd:sat
0xf0 0xde 0x34 0xea
# CHECK: r17:16 += vmpywoh(r21:20,r31:30):rnd:sat
0xf0 0xde 0xb4 0xea
# CHECK: r17:16 += vmpywoh(r21:20,r31:30):<<1:rnd:sat

# Vector multiply word by unsigned half (32x16)
0xb0 0xde 0x54 0xe8
# CHECK: r17:16 = vmpyweuh(r21:20,r31:30):sat
0xb0 0xde 0xd4 0xe8
# CHECK: r17:16 = vmpyweuh(r21:20,r31:30):<<1:sat
0xf0 0xde 0x54 0xe8
# CHECK: r17:16 = vmpywouh(r21:20,r31:30):sat
0xf0 0xde 0xd4 0xe8
# CHECK: r17:16 = vmpywouh(r21:20,r31:30):<<1:sat
0xb0 0xde 0x74 0xe8
# CHECK: r17:16 = vmpyweuh(r21:20,r31:30):rnd:sat
0xb0 0xde 0xf4 0xe8
# CHECK: r17:16 = vmpyweuh(r21:20,r31:30):<<1:rnd:sat
0xf0 0xde 0x74 0xe8
# CHECK: r17:16 = vmpywouh(r21:20,r31:30):rnd:sat
0xf0 0xde 0xf4 0xe8
# CHECK: r17:16 = vmpywouh(r21:20,r31:30):<<1:rnd:sat
0xb0 0xde 0x54 0xea
# CHECK: r17:16 += vmpyweuh(r21:20,r31:30):sat
0xb0 0xde 0xd4 0xea
# CHECK: r17:16 += vmpyweuh(r21:20,r31:30):<<1:sat
0xf0 0xde 0x54 0xea
# CHECK: r17:16 += vmpywouh(r21:20,r31:30):sat
0xf0 0xde 0xd4 0xea
# CHECK: r17:16 += vmpywouh(r21:20,r31:30):<<1:sat
0xb0 0xde 0x74 0xea
# CHECK: r17:16 += vmpyweuh(r21:20,r31:30):rnd:sat
0xb0 0xde 0xf4 0xea
# CHECK: r17:16 += vmpyweuh(r21:20,r31:30):<<1:rnd:sat
0xf0 0xde 0x74 0xea
# CHECK: r17:16 += vmpywouh(r21:20,r31:30):rnd:sat
0xf0 0xde 0xf4 0xea
# CHECK: r17:16 += vmpywouh(r21:20,r31:30):<<1:rnd:sat

# Multiply signed halfwords
0x10 0xdf 0x95 0xe4
# CHECK: r17:16 = mpy(r21.l,r31.l):<<1
0x30 0xdf 0x95 0xe4
# CHECK: r17:16 = mpy(r21.l,r31.h):<<1
0x50 0xdf 0x95 0xe4
# CHECK: r17:16 = mpy(r21.h,r31.l):<<1
0x70 0xdf 0x95 0xe4
# CHECK: r17:16 = mpy(r21.h,r31.h):<<1
0x10 0xdf 0xb5 0xe4
# CHECK: r17:16 = mpy(r21.l,r31.l):<<1:rnd
0x30 0xdf 0xb5 0xe4
# CHECK: r17:16 = mpy(r21.l,r31.h):<<1:rnd
0x50 0xdf 0xb5 0xe4
# CHECK: r17:16 = mpy(r21.h,r31.l):<<1:rnd
0x70 0xdf 0xb5 0xe4
# CHECK: r17:16 = mpy(r21.h,r31.h):<<1:rnd
0x10 0xdf 0x95 0xe6
# CHECK: r17:16 += mpy(r21.l,r31.l):<<1
0x30 0xdf 0x95 0xe6
# CHECK: r17:16 += mpy(r21.l,r31.h):<<1
0x50 0xdf 0x95 0xe6
# CHECK: r17:16 += mpy(r21.h,r31.l):<<1
0x70 0xdf 0x95 0xe6
# CHECK: r17:16 += mpy(r21.h,r31.h):<<1
0x10 0xdf 0xb5 0xe6
# CHECK: r17:16 -= mpy(r21.l,r31.l):<<1
0x30 0xdf 0xb5 0xe6
# CHECK: r17:16 -= mpy(r21.l,r31.h):<<1
0x50 0xdf 0xb5 0xe6
# CHECK: r17:16 -= mpy(r21.h,r31.l):<<1
0x70 0xdf 0xb5 0xe6
# CHECK: r17:16 -= mpy(r21.h,r31.h):<<1
0x11 0xdf 0x95 0xec
# CHECK: r17 = mpy(r21.l,r31.l):<<1
0x31 0xdf 0x95 0xec
# CHECK: r17 = mpy(r21.l,r31.h):<<1
0x51 0xdf 0x95 0xec
# CHECK: r17 = mpy(r21.h,r31.l):<<1
0x71 0xdf 0x95 0xec
# CHECK: r17 = mpy(r21.h,r31.h):<<1
0x91 0xdf 0x95 0xec
# CHECK: r17 = mpy(r21.l,r31.l):<<1:sat
0xb1 0xdf 0x95 0xec
# CHECK: r17 = mpy(r21.l,r31.h):<<1:sat
0xd1 0xdf 0x95 0xec
# CHECK: r17 = mpy(r21.h,r31.l):<<1:sat
0xf1 0xdf 0x95 0xec
# CHECK: r17 = mpy(r21.h,r31.h):<<1:sat
0x11 0xdf 0xb5 0xec
# CHECK: r17 = mpy(r21.l,r31.l):<<1:rnd
0x31 0xdf 0xb5 0xec
# CHECK: r17 = mpy(r21.l,r31.h):<<1:rnd
0x51 0xdf 0xb5 0xec
# CHECK: r17 = mpy(r21.h,r31.l):<<1:rnd
0x71 0xdf 0xb5 0xec
# CHECK: r17 = mpy(r21.h,r31.h):<<1:rnd
0x91 0xdf 0xb5 0xec
# CHECK: r17 = mpy(r21.l,r31.l):<<1:rnd:sat
0xb1 0xdf 0xb5 0xec
# CHECK: r17 = mpy(r21.l,r31.h):<<1:rnd:sat
0xd1 0xdf 0xb5 0xec
# CHECK: r17 = mpy(r21.h,r31.l):<<1:rnd:sat
0xf1 0xdf 0xb5 0xec
# CHECK: r17 = mpy(r21.h,r31.h):<<1:rnd:sat
0x11 0xdf 0x95 0xee
# CHECK: r17 += mpy(r21.l,r31.l):<<1
0x31 0xdf 0x95 0xee
# CHECK: r17 += mpy(r21.l,r31.h):<<1
0x51 0xdf 0x95 0xee
# CHECK: r17 += mpy(r21.h,r31.l):<<1
0x71 0xdf 0x95 0xee
# CHECK: r17 += mpy(r21.h,r31.h):<<1
0x91 0xdf 0x95 0xee
# CHECK: r17 += mpy(r21.l,r31.l):<<1:sat
0xb1 0xdf 0x95 0xee
# CHECK: r17 += mpy(r21.l,r31.h):<<1:sat
0xd1 0xdf 0x95 0xee
# CHECK: r17 += mpy(r21.h,r31.l):<<1:sat
0xf1 0xdf 0x95 0xee
# CHECK: r17 += mpy(r21.h,r31.h):<<1:sat
0x11 0xdf 0xb5 0xee
# CHECK: r17 -= mpy(r21.l,r31.l):<<1
0x31 0xdf 0xb5 0xee
# CHECK: r17 -= mpy(r21.l,r31.h):<<1
0x51 0xdf 0xb5 0xee
# CHECK: r17 -= mpy(r21.h,r31.l):<<1
0x71 0xdf 0xb5 0xee
# CHECK: r17 -= mpy(r21.h,r31.h):<<1
0x91 0xdf 0xb5 0xee
# CHECK: r17 -= mpy(r21.l,r31.l):<<1:sat
0xb1 0xdf 0xb5 0xee
# CHECK: r17 -= mpy(r21.l,r31.h):<<1:sat
0xd1 0xdf 0xb5 0xee
# CHECK: r17 -= mpy(r21.h,r31.l):<<1:sat
0xf1 0xdf 0xb5 0xee
# CHECK: r17 -= mpy(r21.h,r31.h):<<1:sat

# Multiply unsigned halfwords
0x10 0xdf 0xd5 0xe4
# CHECK: r17:16 = mpyu(r21.l,r31.l):<<1
0x30 0xdf 0xd5 0xe4
# CHECK: r17:16 = mpyu(r21.l,r31.h):<<1
0x50 0xdf 0xd5 0xe4
# CHECK: r17:16 = mpyu(r21.h,r31.l):<<1
0x70 0xdf 0xd5 0xe4
# CHECK: r17:16 = mpyu(r21.h,r31.h):<<1
0x10 0xdf 0xd5 0xe6
# CHECK: r17:16 += mpyu(r21.l,r31.l):<<1
0x30 0xdf 0xd5 0xe6
# CHECK: r17:16 += mpyu(r21.l,r31.h):<<1
0x50 0xdf 0xd5 0xe6
# CHECK: r17:16 += mpyu(r21.h,r31.l):<<1
0x70 0xdf 0xd5 0xe6
# CHECK: r17:16 += mpyu(r21.h,r31.h):<<1
0x10 0xdf 0xf5 0xe6
# CHECK: r17:16 -= mpyu(r21.l,r31.l):<<1
0x30 0xdf 0xf5 0xe6
# CHECK: r17:16 -= mpyu(r21.l,r31.h):<<1
0x50 0xdf 0xf5 0xe6
# CHECK: r17:16 -= mpyu(r21.h,r31.l):<<1
0x70 0xdf 0xf5 0xe6
# CHECK: r17:16 -= mpyu(r21.h,r31.h):<<1
0x11 0xdf 0xd5 0xec
# CHECK: r17 = mpyu(r21.l,r31.l):<<1
0x31 0xdf 0xd5 0xec
# CHECK: r17 = mpyu(r21.l,r31.h):<<1
0x51 0xdf 0xd5 0xec
# CHECK: r17 = mpyu(r21.h,r31.l):<<1
0x71 0xdf 0xd5 0xec
# CHECK: r17 = mpyu(r21.h,r31.h):<<1
0x11 0xdf 0xd5 0xee
# CHECK: r17 += mpyu(r21.l,r31.l):<<1
0x31 0xdf 0xd5 0xee
# CHECK: r17 += mpyu(r21.l,r31.h):<<1
0x51 0xdf 0xd5 0xee
# CHECK: r17 += mpyu(r21.h,r31.l):<<1
0x71 0xdf 0xd5 0xee
# CHECK: r17 += mpyu(r21.h,r31.h):<<1
0x11 0xdf 0xf5 0xee
# CHECK: r17 -= mpyu(r21.l,r31.l):<<1
0x31 0xdf 0xf5 0xee
# CHECK: r17 -= mpyu(r21.l,r31.h):<<1
0x51 0xdf 0xf5 0xee
# CHECK: r17 -= mpyu(r21.h,r31.l):<<1
0x71 0xdf 0xf5 0xee
# CHECK: r17 -= mpyu(r21.h,r31.h):<<1

# Polynomial multiply words
0xf0 0xdf 0x55 0xe5
# CHECK: r17:16 = pmpyw(r21,r31)
0xf0 0xdf 0x35 0xe7
# CHECK: r17:16 ^= pmpyw(r21,r31)

# Vector reduce multiply word by signed half (32x16)
0x50 0xde 0x34 0xe8
# CHECK: r17:16 = vrmpywoh(r21:20,r31:30)
0x50 0xde 0xb4 0xe8
# CHECK: r17:16 = vrmpywoh(r21:20,r31:30):<<1
0x90 0xde 0x54 0xe8
# CHECK: r17:16 = vrmpyweh(r21:20,r31:30)
0x90 0xde 0xd4 0xe8
# CHECK: r17:16 = vrmpyweh(r21:20,r31:30):<<1
0xd0 0xde 0x74 0xea
# CHECK: r17:16 += vrmpywoh(r21:20,r31:30)
0xd0 0xde 0xf4 0xea
# CHECK: r17:16 += vrmpywoh(r21:20,r31:30):<<1
0xd0 0xde 0x34 0xea
# CHECK: r17:16 += vrmpyweh(r21:20,r31:30)
0xd0 0xde 0xb4 0xea
# CHECK: r17:16 += vrmpyweh(r21:20,r31:30):<<1

# Multiply and use upper result
0x31 0xdf 0x15 0xed
# CHECK: r17 = mpy(r21,r31)
0x31 0xdf 0x35 0xed
# CHECK: r17 = mpy(r21,r31):rnd
0x31 0xdf 0x55 0xed
# CHECK: r17 = mpyu(r21,r31)
0x31 0xdf 0x75 0xed
# CHECK: r17 = mpysu(r21,r31)
0x11 0xdf 0xb5 0xed
# CHECK: r17 = mpy(r21,r31.h):<<1:sat
0x31 0xdf 0xb5 0xed
# CHECK: r17 = mpy(r21,r31.l):<<1:sat
0x91 0xdf 0xb5 0xed
# CHECK: r17 = mpy(r21,r31.h):<<1:rnd:sat
0x11 0xdf 0xf5 0xed
# CHECK: r17 = mpy(r21,r31):<<1:sat
0x91 0xdf 0xf5 0xed
# CHECK: r17 = mpy(r21,r31.l):<<1:rnd:sat
0x51 0xdf 0xb5 0xed
# CHECK: r17 = mpy(r21,r31):<<1
0x11 0xdf 0x75 0xef
# CHECK: r17 += mpy(r21,r31):<<1:sat
0x31 0xdf 0x75 0xef
# CHECK: r17 -= mpy(r21,r31):<<1:sat

# Multiply and use full result
0x10 0xdf 0x15 0xe5
# CHECK: r17:16 = mpy(r21,r31)
0x10 0xdf 0x55 0xe5
# CHECK: r17:16 = mpyu(r21,r31)
0x10 0xdf 0x15 0xe7
# CHECK: r17:16 += mpy(r21,r31)
0x10 0xdf 0x35 0xe7
# CHECK: r17:16 -= mpy(r21,r31)
0x10 0xdf 0x55 0xe7
# CHECK: r17:16 += mpyu(r21,r31)
0x10 0xdf 0x75 0xe7
# CHECK: r17:16 -= mpyu(r21,r31)

# Vector dual multiply
0x90 0xde 0x14 0xe8
# CHECK: r17:16 = vdmpy(r21:20,r31:30):sat
0x90 0xde 0x94 0xe8
# CHECK: r17:16 = vdmpy(r21:20,r31:30):<<1:sat
0x90 0xde 0x14 0xea
# CHECK: r17:16 += vdmpy(r21:20,r31:30):sat
0x90 0xde 0x94 0xea
# CHECK: r17:16 += vdmpy(r21:20,r31:30):<<1:sat

# Vector dual multiply with round and pack
0x11 0xde 0x14 0xe9
# CHECK: r17 = vdmpy(r21:20,r31:30):rnd:sat
0x11 0xde 0x94 0xe9
# CHECK: r17 = vdmpy(r21:20,r31:30):<<1:rnd:sat

# Vector reduce multiply bytes
0x30 0xde 0x94 0xe8
# CHECK: r17:16 = vrmpybu(r21:20,r31:30)
0x30 0xde 0xd4 0xe8
# CHECK: r17:16 = vrmpybsu(r21:20,r31:30)
0x30 0xde 0x94 0xea
# CHECK: r17:16 += vrmpybu(r21:20,r31:30)
0x30 0xde 0xd4 0xea
# CHECK: r17:16 += vrmpybsu(r21:20,r31:30)

# Vector dual multiply signed by unsigned bytes
0x30 0xde 0xb4 0xe8
# CHECK: r17:16 = vdmpybsu(r21:20,r31:30):sat
0x30 0xde 0x34 0xea
# CHECK: r17:16 += vdmpybsu(r21:20,r31:30):sat

# Vector multiply even haldwords
0xd0 0xde 0x14 0xe8
# CHECK: r17:16 = vmpyeh(r21:20,r31:30):sat
0xd0 0xde 0x94 0xe8
# CHECK: r17:16 = vmpyeh(r21:20,r31:30):<<1:sat
0x50 0xde 0x34 0xea
# CHECK: r17:16 += vmpyeh(r21:20,r31:30)
0xd0 0xde 0x14 0xea
# CHECK: r17:16 += vmpyeh(r21:20,r31:30):sat
0xd0 0xde 0x94 0xea
# CHECK: r17:16 += vmpyeh(r21:20,r31:30):<<1:sat

# Vector multiply halfwords
0xb0 0xdf 0x15 0xe5
# CHECK: r17:16 = vmpyh(r21,r31):sat
0xb0 0xdf 0x95 0xe5
# CHECK: r17:16 = vmpyh(r21,r31):<<1:sat
0x30 0xdf 0x35 0xe7
# CHECK: r17:16 += vmpyh(r21,r31)
0xb0 0xdf 0x15 0xe7
# CHECK: r17:16 += vmpyh(r21,r31):sat
0xb0 0xdf 0x95 0xe7
# CHECK: r17:16 += vmpyh(r21,r31):<<1:sat

# Vector multiply halfwords with round and pack
0xf1 0xdf 0x35 0xed
# CHECK: r17 = vmpyh(r21,r31):rnd:sat
0xf1 0xdf 0xb5 0xed
# CHECK: r17 = vmpyh(r21,r31):<<1:rnd:sat

# Vector multiply halfwords signed by unsigned
0xf0 0xdf 0x15 0xe5
# CHECK: r17:16 = vmpyhsu(r21,r31):sat
0xf0 0xdf 0x95 0xe5
# CHECK: r17:16 = vmpyhsu(r21,r31):<<1:sat
0xb0 0xdf 0x75 0xe7
# CHECK: r17:16 += vmpyhsu(r21,r31):sat
0xb0 0xdf 0xf5 0xe7
# CHECK: r17:16 += vmpyhsu(r21,r31):<<1:sat

# Vector reduce multiply halfwords
0x50 0xde 0x14 0xe8
# CHECK: r17:16 = vrmpyh(r21:20,r31:30)
0x50 0xde 0x14 0xea
# CHECK: r17:16 += vrmpyh(r21:20,r31:30)

# Vector multiply bytes
0x30 0xdf 0x55 0xe5
# CHECK: r17:16 = vmpybsu(r21,r31)
0x30 0xdf 0x95 0xe5
# CHECK: r17:16 = vmpybu(r21,r31)
0x30 0xdf 0x95 0xe7
# CHECK: r17:16 += vmpybu(r21,r31)
0x30 0xdf 0xd5 0xe7
# CHECK: r17:16 += vmpybsu(r21,r31)

# Vector polynomial multiply halfwords
0xf0 0xdf 0xd5 0xe5
# CHECK: r17:16 = vpmpyh(r21,r31)
0xf0 0xdf 0xb5 0xe7
# CHECK: r17:16 ^= vpmpyh(r21,r31)
